<template>
	<view class="ikz-detail">
		<ikz-loading :css-data="loading_css"></ikz-loading>
		<view class="ikz-detail-top">
			<view class="ikz-detail-title">{{detail_info.title}}</view>
			<view class="ikz-detail-time">- {{detail_info.createtime}}</view>
		</view>
		<view class="ikz-detail-content">
			<rich-text :nodes="detail_info.content"></rich-text>
		</view>
	</view>
</template>

<script>
	import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
	var app = getApp();
	import ikz from '@/pages/Common/tools.js';
	export default {
		components: {
			ikzLoading
		},
		data() {
			return {
				id: '',
				nodes: '',
				detail_info: {},
				loading_css: {
					display: 'flex'
				},
			};
		},
		onLoad(options) {
			this.id = options.article_id;
			this.articleDetail((res) => {
				this.loading_css.display = 'none';
			});
		},
		created() {
			// var that = this;
		},
		methods: {
			//请求页面数据
			articleDetail(fn) {
				var path = '/xyb/agent_article/detail';
				var data = {
					id: this.id
				};
				ikz.post(path, data, res => {
					if (res.data.code) {
						var regex2 = new RegExp("(i?)(\<img.*?style=['\"])([^\>]+\>)","gmi");
						 res.data.data.content = res.data.data.content.replace(regex2, "$2max-width:100%;height:auto;$3")
						this.detail_info = res.data.data;
						
					} else {
						uni.showModal({
							title: '提示',
							content: res.data.msg,
							showCancel: false,
							success: function(res) {}
						});
					}
					fn();
					// if(that.pull_status){
					// 	this.$emit("change",'pull');
					// }
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		background: #F3F3F3;
	}

	.ikz-detail {
		width: 100%;
		height: 100%;
		background: #fff;
	}

	.ikz-detail-top {
		box-sizing: border-box;
		width: 100%;
		padding: 40rpx;
		border-bottom: 1px solid #eee;
	}

	.ikz-detail-title {
		font-weight: 800;
	}

	.ikz-detail-time {
		color: #888888;
		font-size: 25rpx;
		margin-top: 15rpx;
	}

	.ikz-detail-content {
		box-sizing: border-box;
		padding: 40rpx;
	}
</style>